const express = require('express');
const router = express.Router();
const WordController = require('../controllers/word.controller');
const authMiddleware = require('../middlewares/auth.middleware');

// 所有路由都需要认证
router.use(authMiddleware);

// 创建新的单词会话
router.post('/sessions', WordController.createSession);

// 在特定会话中生成单词（修改路径以避免冲突）
router.post('/sessions/:sessionId/generate', WordController.generateWords);

// 获取历史会话列表
router.get('/sessions', WordController.getSessions);

// 获取特定会话的单词记录
router.get('/sessions/:sessionId/words', WordController.getSessionWords);

// 更新单词通关状态
router.put('/messages/:messageId/completion', WordController.updateWordCompletion);

// 删除会话
router.delete('/sessions/:sessionId', WordController.deleteSession);

// 删除单词消息
router.delete('/messages/:messageId', WordController.deleteWordMessage);

// 修改会话名称
router.put('/sessions/:sessionId', WordController.updateSessionName);

// 添加收藏
router.post('/favorites', WordController.addFavorite);

// 取消收藏
router.delete('/favorites/:favoriteId', WordController.removeFavorite);

// 获取收藏列表
router.get('/favorites', WordController.getFavorites);

module.exports = router; 